package com.base.cn.platform.os.controller.course.classes.personal;

import com.base.cn.platform.os.common.utils.DataUtil;
import com.base.cn.platform.os.common.utils.result.ResultUtil;
import com.base.cn.platform.os.controller.cmmon.ApiBaseController;
import com.base.cn.platform.os.service.course.classes.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Map;


/**
 * 用户班级接口
 *
 * @author s.li
 * @create 2018-09-17-10:52
 */
@RestController
@RequestMapping("/api/classes/personal")
public class ApiClassesPersonalController extends ApiBaseController {

    @Autowired
    private ClassesService classesService;


    /**
     * 获取用户加入的班级列表
     * @param userId 用户ID
     * @param currentPage 页码
     * @return Map<String,Object>
     */
    @RequestMapping("/getMyClass")
    public Map<String,Object> getMyClass(@RequestParam("userId") BigDecimal userId,
                                         @RequestParam(value = "currentPage",required = false,defaultValue = "1") int currentPage){
        if(!DataUtil.idIsNotNull(userId)){
            return ResultUtil.ERROR("请登录后再操作");
        }
        Map<String, Object> classesPersonalListPage = classesService.findClassesPersonalListPage(userId, currentPage, 5);
        return ResultUtil.SUCCESS(classesPersonalListPage);
    }
}
